home *** CD-ROM | disk | FTP | other *** search
/ PsL Monthly 1993 December / PSL Monthly Shareware CD-ROM (December 1993).iso / prgmming / dos / c / progbar.exe / MAKEREZ.CPP < prev    next >
C/C++ Source or Header  |  1992-10-12  |  3KB  |  110 lines

  1. /*---------------------------------------------------------*/
  2. /*                                                         */
  3. /*   MakeRez.cpp                                           */
  4. /*   Creates a MyDialog (derives from TDialog) Resource    */
  5. /*                                                         */
  6. /*   based on Turbo Vision Hello World Demo Source File    */
  7. /*---------------------------------------------------------*/
  8. #define Uses_TObject
  9. #define Uses_TKeys
  10. #define Uses_TApplication
  11. #define Uses_TEvent
  12. #define Uses_TRect
  13. #define Uses_TDialog
  14. #define Uses_TStaticText
  15. #define Uses_TButton
  16. #define Uses_TMenuBar
  17. #define Uses_TSubMenu
  18. #define Uses_TMenuItem
  19. #define Uses_TStatusLine
  20. #define Uses_TStatusItem
  21. #define Uses_TStatusDef
  22. #define Uses_TDeskTop
  23. #define Uses_TStreamableClass
  24. #define Uses_TResourceFile
  25. #define Uses_TResourceCollection
  26. #define Uses_MsgBox
  27. #define Uses_fpstream
  28.  
  29. #include <tv.h>
  30. #include "tprogbar.h"
  31.  
  32. __link(RWindow);
  33. __link(RGroup);
  34. __link(RDialog);
  35. __link(RFrame);
  36. __link(RResourceCollection);
  37. __link(RCluster);
  38. __link(RButton);
  39. __link(RProgressBar);
  40.  
  41. #include <string.h>
  42. #include <stdlib.h>
  43.  
  44. const char rezFileName[] = "MY.REZ";
  45.  
  46. void makerez()
  47. {
  48.    fpstream *ofps=0;
  49.  
  50.  
  51.    cout<< "Creating "<< rezFileName << endl;
  52.  
  53.    ofps = new fpstream( rezFileName, ios::out|ios::binary );
  54.    if( !ofps->good() )
  55.     {
  56.       cerr<< rezFileName <<": init failed..."<<endl;
  57.       exit(1);
  58.     }
  59.  
  60.    TResourceFile *myRez;
  61.    myRez = new TResourceFile( ofps );
  62.    if( !myRez )
  63.    {
  64.      cerr<< "Resource file init failed..."<<endl;
  65.      exit(1);
  66.    }
  67.  
  68.    TDialog *pd = new TDialog(TRect(0,0,60,15),"Example Progress Bar");
  69.    pd->options |= ofCentered;
  70.    pd->flags &= ~wfClose;
  71.    TProgressBar *pbar = new TProgressBar(TRect(2,2,pd->size.x-2,3),300);
  72.    pd->insert(new TButton(TRect(10,pd->size.y-3,pd->size.x-10,pd->size.y-1),"~C~ancel",cmCancel,bfDefault));
  73.  
  74.    if( !pbar )
  75.    {
  76.     cerr<< "Progress Bar init failed..."<<endl;
  77.     exit(1);
  78.     }
  79.  
  80.    if( !pd )
  81.    {
  82.     cerr<< "Dialog Box init failed..."<<endl;
  83.     exit(1);
  84.     }
  85.  
  86.    /*
  87.       We need a separate TProgressBar stream because you need that object
  88.       visible outside the dialog box in order to update it via
  89.                TProgressBar::update(double progress);
  90.    */
  91.    myRez->put( pbar, "theProgressBar");
  92.  
  93.    // Here is the stream for the dialog box.
  94.    myRez->put( pd, "theDialogBox");
  95.  
  96.    TObject::destroy( pd );
  97.    TObject::destroy( pbar );
  98.    TObject::destroy( myRez);
  99. }
  100.  
  101. int main()
  102. {
  103.     makerez();
  104.     return 0;
  105. }
  106.  
  107.  
  108.  
  109.  
  110.